<?php
/**
 * Created by PhpStorm.
 * User: LP
 * Date: 2018/4/10
 * Time: 15:19
 */
class AiNongpayBackAction extends Action{
    public function callback(){
        echo "success";
        $sn =  $_POST['merOrderId'];
        $merId = $_POST['merId'];
        $respCode = $_POST['respCode'];
        Session::switchCustomer(0);
        if($respCode == AiNongPaySuccess){
            $aiNongpaySetting = D("customer_mall_ainongpay_setting");
            $orderModel = M("module_product_order");
            $aiNongpayInfo = $aiNongpaySetting->where("merId='$merId'")->find();
            $cid = $aiNongpayInfo['customerId'];
            Session::switchCustomer($cid);
            $whereOrderSn["tempSerialNumber"] = $sn;
            $status = $orderModel->where($whereOrderSn)->getField("status");
            if($status!=order_status_refund){
                $oidArr = $orderModel->where($whereOrderSn)->getField('id' ,true);
                $oid = implode(",", $oidArr);
                R('Product/deductProductInventory', array($oid));
                $result = ProductOrder::updateOrderDone($cid, $oid, '', true);
            }
        }
        return "success";
    }
}